package com.zhdl.hardware.modules.repository;

import com.project.common.repository.BaseRepository;
import com.zhdl.hardware.modules.entity.DeviceInfo;
import com.zhdl.hardware.modules.entity.ProcessStep;
import com.zhdl.hardware.modules.entity.ProcessSystem;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface DeviceRepository extends BaseRepository<DeviceInfo, String> {
    @Query(value = "select di from DeviceInfo di where di.deviceId in (select dp.deviceId from DeviceProcess dp)")
    List<DeviceInfo> findDeviceInfoById();

    @Query(value = "select ps from ProcessSystem ps where ps.processId  = :processId")
    ProcessSystem findSystemByProcessId(@Param("processId") int processId);

    @Query(value = "select ps from ProcessStep ps where ps.processId  = :processId")
    List<ProcessStep> findStepByProcessId(@Param("processId") int processId);

}
